'''
语法：
class 类名:
    # 初始化方法（定义属性）
    def __init__(self, 参数1, 参数2, ...):
        self.属性1 = 参数1  # self 代表实例本身
        self.属性2 = 参数2

    # 定义方法（行为）
    def 方法名(self, 参数...):
        # 方法逻辑
        return 结果
'''
#from com.shaungti.prepare.FunctionDemo import user_name


class Students:
    def __init__(self,num,user_name,sex,mobile,score):
        """
        初始化数据，类比于java的构造函数
        :param num:
        :param user_name:
        :param sex:
        :param mobile:
        :param socre:
        """
        self.num = num
        self.user_name = user_name
        self.sex = sex
        self.mobile = mobile
        self.score = score

    def update_score(self,new_score):
        """
        修改分数
        :param new_score:
        :return:
        """
        self.score = new_score
        print(f"{self.user_name}考试后成绩为：{self.score}")

    def get_student_info(self):
        return f"姓名：{self.user_name}，学号：{self.num}，性别：{self.sex}，手机号：{self.mobile}，分数：{self.score}"

# 创建对象
stu1 = Students(20220010,"张三","男","15178831894",88.8)
stu2 = Students(20220011,"小美","女","15178831895",89)

# 属性调用
print(stu1.user_name)
stu2.score = 91
print(stu2.score)

# 方法调用
print(stu1.get_student_info())
stu1.update_score(91)
print(stu1.get_student_info())
print(stu2.get_student_info())